# Maintainer: Alexander F. Rødseth <xyproto@archlinux.org>
# Contributor: Tom Newsom <Jeepster@gmx.co.uk>
# Contributor: tobias <tobias@archlinux.org>
# Contributor: red_over_blue
# Contributor: neri

pkgname=povray
epoch=2
pkgver=3.7.0.10
pkgrel=7
_v=${pkgver%.*.*} # 3.7
pkgdesc='Script based raytracer for creating 3D graphics'
arch=(loong64 x86_64)
license=(AGPL3)
url='https://povray.org/'
depends=(boost-libs imath libpng libtiff openexr)
makedepends=(boost git glu)
backup=(etc/povray/$_v/povray.conf
        etc/povray/$_v/povray.ini)
source=("$pkgname-$pkgver.tar.gz::https://github.com/POV-Ray/povray/archive/v$pkgver.tar.gz")
b2sums=('b9b448bafc1664d7378168905125ef8b60ac5e8a3a213d6216dd0219b2fad0bc43a5c6d8f8f3d8172ff43bcc9a3f11806b2ff04d3b965914fd628c929e46560b')

prepare() {
  cd $pkgname-$pkgver
  rm -frv libraries/ilmbase/Imath
  cd unix
  sed 's/automake --w/automake --add-missing --w/g' -i prebuild.sh
  sed 's/dist-bzip2/dist-bzip2 subdir-objects/g' -i configure.ac
  ./prebuild.sh
  cd ..
  ./bootstrap
}

build() {
  cd $pkgname-$pkgver
  ./configure \
    LIBS="-lboost_system -lboost_thread" \
    COMPILED_BY='Arch Linux' \
    --prefix=/usr \
    --sysconfdir=/etc
  make CXXFLAGS+='-std=c++11 -lboost_system -lboost_thread -DBOOST_BIND_GLOBAL_PLACEHOLDERS=1 -w'
}

package() {
  cd $pkgname-$pkgver
  install -d "$pkgdir"/usr/share/{doc/,}"$pkgname-$_v"
  cp -r icons include ini scenes scripts "$pkgdir/usr/share/$pkgname-$_v"
  cp -r doc "$pkgdir/usr/share/doc/$pkgname-$_v"
  install -Dm755 unix/povray "$pkgdir/usr/bin/povray"
  install -Dm644 povray.conf "$pkgdir/etc/povray/$_v/povray.conf"
  install -Dm644 povray.ini "$pkgdir/etc/povray/$_v/povray.ini"
  install -Dm644 povray.1 "$pkgdir/usr/share/man/man1/povray.1"
}

# getver: povray.org/documentation
